<template>
    <el-container class="homess">
      <el-header class="header"><span>电商后台管理系统</span><el-button type="info" @click="notgo">退出</el-button></el-header>
      <el-container>
        <el-aside width="200px" class="asids">
          <el-menu
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            router>
             <el-submenu :index="item.id + ''" v-for="item in menulist" :key="item.id">
               <template slot="title">
               <i class="el-icon-location"></i>
               <span>{{ item.authName }}</span>
               </template>
                 <el-menu-item :index="subitem.path + ''" v-for="subitem in item.children" :key="subitem.id">
                  <template slot="title">
                    <i class="el-icon-location"></i>
                    <span>{{ subitem.authName }}</span>
                  </template>
                </el-menu-item>
             </el-submenu>
          </el-menu>
        </el-aside>
        <el-main><router-view></router-view></el-main>
      </el-container>
    </el-container>
</template>

<script>
// @ is an alias to /src


export default {
  name: 'HomeView',
  data() {
    return {
      menulist: []
    }
  },
  created() {
    this.getMenuList()
  },
  methods: {
    notgo() {
      window.sessionStorage.clear()
      this.$router.push('/login')
    },
    async getMenuList() {
      const { data: res } =  await this.$http.get('menus')
      console.log(res);
      this.menulist = res.data
    }
  }
}
</script>

<style scoped lang="less">
  .homess {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
  }
  /deep/ .header {
    display: flex;
    background-color: #aaa;
    size: 30px;
  }
  .asids {
    background-color: #545c64;
  }
  .el-main {
    overflow: scroll;
    height: 100vh;
  }
</style>
